package leetcode.biweekly.week97;

import java.util.HashSet;
import java.util.Set;

//Solution2Test
public class Solution2 {

	public int maxCount(int[] banned, int n, int maxSum) {
		Set<Integer> set = new HashSet<>();
		for (int num : banned) {
			set.add(num);
		}
		int ans = 0;
		for (int i = 1; i <= n && maxSum >= i; i++) {
			if (!set.contains(i)) {
				ans++;
				maxSum -= i;
			}
		}
		return ans;
	}

}
